<template>
  <view class="">
    <uni-forms :modelValue="pwdInfoForm">
      <uni-forms-item label="标题" name="title">
        <uni-easyinput type="text" v-model="pwdInfoForm.title" placeholder="请输入标题" />
      </uni-forms-item>
      <uni-forms-item label="用户名" name="username">
        <uni-easyinput type="text" v-model="pwdInfoForm.username" placeholder="请输入用户名" />
      </uni-forms-item>
      <uni-forms-item label="密码" name="password">
        <uni-easyinput type="text" v-model="pwdInfoForm.password" placeholder="请输入密码" />
      </uni-forms-item>
      <uni-forms-item label="链接" name="link">
        <uni-easyinput type="text" v-model="pwdInfoForm.link" placeholder="请输入链接" />
      </uni-forms-item>
      <uni-forms-item label="说明" name="remark">
        <!--        <uni-easyinput type="text" v-model="pwdInfoForm.remark" placeholder="请输入说明" />-->
        <textarea class="textarea" v-model="pwdInfoForm.remark" placeholder="请输入说明"
                  style="border: 1rpx solid #ccc;width: 100%;height: 100%;padding: 10px;"></textarea>
      </uni-forms-item>
      <button @click="submitForm" type="primary" style="margin-top: 5vh;">保存</button>
    </uni-forms>
  </view>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useDataStore } from '@/stores/modules/data'

const dataStore = useDataStore()
const pwdInfoForm = ref<PwdInfo>({
  id: 0,
  group_id: 0,
  group_title: '',
  title: '',
  username: '',
  password: '',
  link: '',
  remark: '',
})
onMounted(() => {
  console.log('index onMounted')
  pwdInfoForm.value = dataStore.getCurPwdInfo()
})


const submitForm = () => {
  console.log('submitForm', pwdInfoForm.value)
  dataStore.setCurPwdInfo(pwdInfoForm.value)
}

</script>


<style scoped lang="scss">

</style>
